home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / recode.lha / recode-3.2.4 / checkit < prev    next >
Text File  |  1992-07-16  |  2KB  |  80 lines

  1. :
  2. # Script to help checking `recode'.
  3. # Copyright (C) 1991 Free Software Foundation, Inc.
  4. # Francois Pinard <pinard@iro.umontreal.ca>, 1991.
  5.  
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2, or (at your option)
  9. # any later version.
  10.  
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15.  
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. # Use this script by `checkit [-v] FILE BEFORE AFTER'.  It does
  21. # various check of recoding FILE from BEFORE to AFTER or vice-versa.
  22. # The -v parameter gives more verbose output.  Exit with a non-zero
  23. # status if any error found.
  24.  
  25. if test "$1" = -v; then
  26.   shift
  27.   verbose=1
  28. fi
  29.  
  30. # Select methods to be tested by studying `configure' output.
  31.  
  32. eval `grep '^DEFS=' config.status`
  33. methods=i
  34. case "$DEFS" in
  35.   *HAVE_POPEN*) methods="$methods o" ;;
  36. esac
  37. case "$DEFS" in
  38.   *HAVE_PIPE*) methods="$methods p" ;;
  39. esac
  40.  
  41. # Echo the tested sequence of steps.
  42.  
  43. if test -n "$verbose"; then
  44.   ./recode -vi < /dev/null $2:$3
  45.   ./recode -vi < /dev/null $3:$2
  46. fi
  47.  
  48. # Try all methods, both in filter and in non-filter modes.
  49.  
  50. for method in $methods; do
  51.   test -n "$verbose" && echo "Checking -$method between $2 and $3 on stdin"
  52.   ./recode -$method < $1 $2:$3 | ./recode -$method $3:$2 > checkit.tmp
  53.   if diff $1 checkit.tmp; then
  54.     :
  55.   else
  56.     echo
  57.     echo "*** error in: recode -$method < $1 $2:$3  [or $3:$2]"
  58.     rm checkit.tmp
  59.     exit 1
  60.   fi
  61.  
  62.   test -n "$verbose" && echo "Checking -$method between $2 and $3 on file"
  63.   cp $1 checkit.tmp
  64.   ./recode -$method $2:$3 checkit.tmp
  65.   ./recode -$method $3:$2 checkit.tmp
  66.   if diff $1 checkit.tmp; then
  67.     :
  68.   else
  69.     echo
  70.     echo "*** error in: recode -$method   $1 $2:$3  [or $3:$2]"
  71.     rm checkit.tmp
  72.     exit 1
  73.   fi
  74. done
  75.  
  76. # Return success.
  77.  
  78. rm checkit.tmp
  79. exit 0
  80.